package cn.lyq.card.ui.wallet

import cn.lyq.card.base.SimpleVM
import cn.lyq.card.utils.EncryptUtils


class WalletVM : SimpleVM() {

    val pageSize = 20

    fun getWalletInfo() = simpleEmit {
        repository.userService.getWalletInfo()
    }

    fun getTypeList() = simpleEmit {
        repository.userService.getBillType()
    }

    fun getBillList(type: Int, page: Int) = simpleEmit {
        repository.userService.getBill(page, pageSize, type.toString())
    }

    fun getBankCardInfo() = simpleEmit {
        repository.userService.getBankCardInfo()
    }

    fun getCashRecord(page: Int, type: Int) = simpleEmit {
        repository.userService.getCashRecord(page, pageSize, type)
    }

    fun applyCash(price: Double, pwd: String, type: Int) = simpleEmit {
        val pwdEncrypt = EncryptUtils.encryptPwd(pwd)
        repository.userService.applyCash(price.toString(), pwdEncrypt, type)
    }
}